﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Chinaer.Core.BaseCore;
using Chinaer.Model.Common;

namespace Chinaer.Core.Helper.Mobile
{
    /// <summary>
    /// json数据的Helper类
    /// </summary>
    public class JsonHelper
    {
        /// <summary>
        /// 返回json数据结果的静态方法
        /// </summary>
        /// <param name="flag"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public static string GetJsonResult(bool flag, string message)
        {
            JsonResult jsonResult = new JsonResult()
            {
                Success = flag,
                ErrorMessage = message
            };
            return JsonConvert.SerializeObject(jsonResult);
        }
        public static string GetJsonResult(JsonResult jsonResult)
        {
            return JsonConvert.SerializeObject(jsonResult);
        }
        public static string Serialize(object obj)
        {
            return Newtonsoft.Json.JsonConvert.SerializeObject(obj);
        }

    }
}
